package main

import (
	"golang_note/day08_http/gin/filerouter"
	userrouter "golang_note/day08_http/gin/userRouter"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	app := gin.Default()
	app.LoadHTMLFiles("../../html/index.html", "../../html/change.html", "../../html/uploadfile.html")
	app.Static("/static", "../../static")
	app.GET("/login", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", nil)
	})
	app.GET("/change", func(c *gin.Context) {
		c.HTML(http.StatusOK, "change.html", nil)
	})
	app.GET("/file", func(c *gin.Context) {
		c.HTML(http.StatusOK, "uploadfile.html", nil)
	})
	userGroup := app.Group("/user")
	{
		userGroup.POST("/register", userrouter.UserRegister)
		userGroup.POST("/changpassword", userrouter.UserChangePassword)
	}
	fileGroup := app.Group("/file")
	{
		fileGroup.POST("/uploadinit", filerouter.FileRouterinit)
		fileGroup.POST("/uploadpart", filerouter.UploadPartHandel)
		fileGroup.POST("/compilefile", filerouter.CompleteUploadHandler)
	}
	app.Run(":9090")
}
